<!DOCTYPE html>
<html>
<head>
<!-- 统一meta标签 -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- 360浏览器默认使用极速内核 -->
<meta content="webkit" name="renderer">
<title>主页</title>
<!--
先请求http://www.cross.com/static/login.html 模拟登陆
 访问地址http://static.cross.com:9999/static/crosscookie/needLogin2.html-->
</head>
<body>
	<div id="testId"></div>
	<div id="testId2"></div>
	<div id="testId3"></div>
</body>
<script src="../jquery-1.11.1.js"></script>
<!-- 请求带cookie -->
<script type="text/javascript">
var cross = {};
cross.needLogin = function() {
    var _this = {
        init : function() {
            $.ajax("http://www.cross.com:8888/user/findUserMessageNeedLogin.action", {
                type : 'post',
                dataType : 'json',
                data : JSON.stringify({
                    hmac : "",
                    params : {}
                }),
                contentType : "application/json;charset=utf-8",
                success : function(data) {
                	if(data.data){
                		 $('#testId').text(JSON.stringify(data.data));
                	}else{
                		 $('#testId').text(data.msg);
                	}
                   
                },
                error : function(response, textStatus, errorThrown) {
                    $('#testId2').append(textStatus);
                    $('#testId3').append(errorThrown);
                },
                headers:{
                	"X-Requested-With":"XMLHttpRequest"
                },
                xhrFields: {   //浏览器携带cookie
                    withCredentials: true 
                }
            });
        }
    };
    return _this;
}();

$(function() {
    cross.needLogin.init()
});
</script>
</html>


